<html>
<head><meta charset="utf-8"><title>tracing assertions · t-compiler/wg-llvm · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/index.html">t-compiler/wg-llvm</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/tracing.20assertions.html">tracing assertions</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="200781301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/tracing%20assertions/near/200781301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/tracing.20assertions.html#200781301">(Jun 13 2020 at 19:26)</a>:</h4>
<p>Now that AVR support has landed in nightly, I'm trying to pick up some of my previous work. I'm running into this at the moment:</p>
<div class="codehilite"><pre><span></span><code>Assertion failed: (castIsValid(op, S, Ty) &amp;&amp; &quot;Invalid cast!&quot;), function Create, file /Users/shep/Projects/rust/src/llvm-project/llvm/lib/IR/Instructions.cpp, line 2741.
</code></pre></div>


<p>I can see it in the debugger, but don't have much ability to see what's what —</p>
<div class="codehilite"><pre><span></span><code>(lldb)
librustc_driver-ed290098f911a9dd.dylib was compiled with optimization - stepping may behave oddly; variables may not be available.
frame #5: 0x000000010cadfa29 librustc_driver-ed290098f911a9dd.dylib`llvm::CastInst::Create(op=&lt;unavailable&gt;, S=0x00007fb2719e7bb8, Ty=0x00007fb2d26528d0, Name=0x000070000da2f390, InsertBefore=0x0000000000000000) at Instructions.cpp:2741:3 [opt]
   2738
   2739 CastInst *CastInst::Create(Instruction::CastOps op, Value *S, Type *Ty,
   2740   const Twine &amp;Name, Instruction *InsertBefore) {
-&gt; 2741   assert(castIsValid(op, S, Ty) &amp;&amp; &quot;Invalid cast!&quot;);
   2742   // Construct and return the appropriate CastInst subclass
   2743   switch (op) {
   2744   case Trunc:         return new TruncInst         (S, Ty, Name, InsertBefore);

(lldb) frame variable op
(llvm::Instruction::CastOps) op = &lt;variable not available&gt;

(lldb) p S-&gt;dump()
 %value.1 = load i8*, i8** %29, align 1, !dbg !558, !nonnull !52

(lldb) p Ty-&gt;dump()
i1 (%&quot;fmt::::Opaque&quot;*, %&quot;fmt::Formatter&quot;*) addrspace(1)*
</code></pre></div>


<p>I did <a href="https://github.com/avr-rust/rust/issues/143#issuecomment-643652619">make some changes</a>, which are possible to cause this.</p>



<a name="200781469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/tracing%20assertions/near/200781469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/tracing.20assertions.html#200781469">(Jun 13 2020 at 19:30)</a>:</h4>
<p>As a bit of background, AVR has separate address spaces for data and code, and you can't cast between them</p>



<a name="200781487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/tracing%20assertions/near/200781487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/tracing.20assertions.html#200781487">(Jun 13 2020 at 19:30)</a>:</h4>
<p>so my bigger goal is to figure out how to preserve the appropriate metadata</p>



<a name="200782194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/tracing%20assertions/near/200782194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/tracing.20assertions.html#200782194">(Jun 13 2020 at 19:39)</a>:</h4>
<p>We <a href="https://github.com/rust-lang/rust/commit/91bff8ccdfddd119a2239e625bfb52703844f227">added some hacks in</a>, but those are very targeted (and ugly!)</p>



<a name="200782528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/tracing%20assertions/near/200782528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/tracing.20assertions.html#200782528">(Jun 13 2020 at 19:45)</a>:</h4>
<p>Commenting out <code>core::fmt::run</code> and replacing it with <code>Ok(())</code> gets past that error, so I'm guessing it has something to do with the function pointer cast(?) there.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>